import loading from './Loading.vue'
import Vue from 'vue'

// 获取loading组件的构造函数，构造loading组件
const LoadingConstructor = Vue.extend(loading)

let loadingInstance = null
const serve = () => {
    // 创建loading实例
    if (!loadingInstance) {
        loadingInstance = new LoadingConstructor()
    }

    //将组件挂载到指定元素
    loadingInstance.$mount(document.createElement('div'))
    //将组件挂载的元素一添加到body元素下
    document.body.appendChild(loadingInstance.$el)
    Vue.nextTick(() => {
        loadingInstance.show = true
    })
    return loadingInstance;
}
export default serve